home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0133_Creating a Log Diary.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  2.4 KB  |  73 lines

  1. {
  2. I wrote a similar little program, to register who are using a particular
  3. program on the network. I think you can get the same done using a
  4. simple batch file system - since this is only for statistical information.
  5. I would use the following batch commands in STUDENT.BAT:
  6. LOGIN %1
  7. REGISTER H:\wherever\LOG.REG %1
  8.  
  9. It assumes your login script makes an enviroment variable called
  10. NAME=usersname
  11. But used like above it doen't matter.
  12. Call STUDENT.BAT with
  13. STUDENT studentloginname
  14.  
  15. All that register.exe needs to do is to take it's parameter, add a date and
  16. time stamp (GetDate & GetTime) and writeln everything to a text file.
  17.  
  18. Yes, there is no protection again normal, unregistered logins, but then that
  19. is not what you asked for?
  20. BTW, I edited it a bit in the mailer - there may be a sintax error...
  21.  
  22. Cheers,
  23. Harry.
  24. {------------------------------------------------------------------------}
  25. program Register;
  26. {   Used to register users of a program. }
  27. uses Dos;
  28. var
  29.    F:text;
  30.    FN,Remark:string;
  31.    YY,MM,DD,DOW,H,M,S,ss,Retry:word;
  32.  
  33. function D0(i:word):string;
  34.    var S:string;
  35.    begin
  36.       str(I,S);
  37.       if length(S)=1 then S:='0'+S;
  38.       D0:=S;
  39.    end;
  40.  
  41. begin
  42.    if ParamCount<1 then begin
  43.       writeln('Use: REGISTER  path\filename.REG  remark');
  44.       writeln('   where path\file.REG is a text file where the user will be logged.');
  45.       writeln('   The user must have read/write access to this path.');
  46.       writeln('   The remark can be anything, ex.: "logging_in" or "logging_out"');
  47.    end else begin
  48.       FN:=ParamStr(1);
  49.       if ParamCount>=2 then Remark:=paramstr(2) else Remark:='';
  50.       if copy(FN,length(FN)-3,4)<>'.REG' then
  51.          writeln('Invalid log file: ',FN)
  52.       else begin
  53.          assign(F,ParamStr(1));
  54.          {$I-}
  55.          if FSearch(ParamStr(1),'')<>ParamStr(1) then rewrite(F);
  56.          retry:=255;
  57.          repeat append(F); dec(retry); until (retry=0) or (IOResult=0);
  58.          {This is only for if the program tries to register two users at
  59.           the same time}
  60.          if IOResult<>0 then begin
  61.             writeln('Log file not found/accesable.');
  62.             halt;
  63.          end;
  64.          {$I+}
  65.          GetDate(YY,MM,DD,DOW);
  66.          GetTime(H,M,S,ss);
  67.          writeln(F,D0(YY),'/',D0(MM),'/',D0(DD),', ',
  68.                    D0(H),'h',D0(M),':',D0(S),',  ',
  69.                    GetEnv('NAME'),',  ',Remark);
  70.          close(F);
  71.       end;
  72.    end;
  73. end.